#ifndef IPC_H
#define IPC_H
#include <stdio.h>
#include <os/queue.h>
#include <os/sched.h>
#include <os/string.h>
#include <os/mm.h>
#define USING 1
#define NOTUSING 0
#define MAX_MBOX_LENGTH (64)
typedef struct barrier
{
    int count;
    int num_waiting;
    int inuse;
    int key;
    queue_t block_queue;
} barrier_t;

typedef struct condition
{
    int inuse;
    int key;
    int num_waiting;
    queue_t block_queue;
} condition_t;

typedef struct mbox
{
    char buff[MAX_MBOX_LENGTH];
    int nbytes;
    char *name;
    int refer_num;
    int status;
    queue_t send_queue;
    queue_t recv_queue;
} mbox_t;

typedef struct shmpage{
    int key;
    int refer_num;
    uint64_t pa;
}shmpage_t;

int do_barrier_init(int key,unsigned count);
int do_barrier_wait(int key);
int do_barrier_destroy(int key);

int do_cond_init(int key);
int do_cond_wait(int key,int lock_id);
int do_cond_destroy(int key);
int do_cond_signal(int key);
int do_cond_broadcast(int key);

int do_mbox_open(char *);
void do_mbox_close(int);
void do_mbox_send(int, void *, int);
void do_mbox_recv(int, void *, int);

void* do_shmpageget(int key);
void do_shmpagedt(void *addr);
#endif